package com.yesido.springcloud.controller;

import com.yesido.pojo.User;
import com.yesido.springcloud.feign.service.FeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yesido
 * @description feign rpc调用
 * @date 2023-06-06
 * @Version 8.3
 */

@RestController
@RequestMapping("feign")
@Slf4j
public class FeignController {
    @Resource
    private FeignService feignService;
    /**
     * http接口都能访问 我为啥需要eureka
     * @param id
     * @return
     */
    @GetMapping("/getUserById/{id}")
    public User getUserById(@PathVariable("id") Integer id){
        User user = feignService.getUserById(id);
        log.info("通过feign rpc调用的后的结果 user={}",user);
        return user;
    }
}
